<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        function createmingStateChange(url,progress,finished){
            var xhr = new XMLHttpRequest(),
                reveived =0;
                xhr.open('GET',url);
                xhr.onreadystatechange = function(){
                     if(xhr.readyState == 3){
                           var result =  xhr.responesText.subString(reveived);
                                reveived += result.length;
                               progress(result);
                     }else if(xhr.readyState == 4){
                             finished(data)
                     }
                }
                var client = createmingStateChange('streaming.php',
                          function(data){console.log('reveived:'+data)},
                          function(){console.log('Done')} 
                          )
    </script>
</body>
</html>